#include <bits/stdc++.h>

#define in read()
#define pb push_back
#define vec vector<int>

using namespace std;

typedef unsigned long long ull;

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return x * sgn;}

const int N = 3e5+10;

mt19937 rnd(19491001);

int n,q,a[N],rt[N],ch[N<<5][2];
int dfn[N],siz[N],top[N],tim,L,fa[N],son[N],nodenum,dep[N];
vec G[N];
ull key[N],s[N<<5];

void upd(int &y,int x,int v,int l = 1,int r = n){
	y = ++nodenum; s[y] = s[x] ^ key[v]; ch[y][0] = ch[x][0]; ch[y][1] = ch[x][1]; if(l == r) return; int mid = l + r >> 1;
	if(v <= mid) upd(ch[y][0],ch[x][0],v,l,mid); else upd(ch[y][1],ch[x][1],v,mid + 1,r);
}

void dfs(int x,int p){upd(rt[x],rt[p],a[x]); fa[x] = p; siz[x] = 1; dep[x] = dep[p] + 1; for(auto y : G[x]) if(y ^ p) dfs(y,x),siz[x] += siz[y],son[x] = siz[y] > siz[son[x]] ? y : son[x];}

void dfs1(int x,int anc){top[x] = anc; dfn[x] = ++tim; if(son[x]) dfs1(son[x],anc); for(auto y : G[x]) if(y ^ fa[x] && y ^ son[x]) dfs1(y,y);}

int lca(int x,int y){while(top[x] ^ top[y]){if(dep[top[x]] < dep[top[y]]) swap(x,y); x = fa[top[x]];} return dep[x] < dep[y] ? x : y;}

ull sum(int x,int y,int l,int r){if(a[L] >= l && a[L] <= r) return s[x] ^ s[y] ^ key[a[L]]; else return s[x] ^ s[y];}

int query(int x,int y,int xl,int xr,int l = 1,int r = n){
	if(xl == l && xr == r){
		if(sum(x,y,l,r)){
			if(l == r) return l; int mid = l + r >> 1;
			if(sum(ch[x][0],ch[y][0],l,mid)) return query(ch[x][0],ch[y][0],xl,mid,l,mid);
			else return query(ch[x][1],ch[y][1],mid + 1,xr,mid + 1,r);
		}else return -1;
	} int mid = l + r >> 1;
	if(xr <= mid) return query(ch[x][0],ch[y][0],xl,xr,l,mid);
	else if(xl > mid) return query(ch[x][1],ch[y][1],xl,xr,mid + 1,r);
	else{int ans = query(ch[x][0],ch[y][0],xl,mid,l,mid); if(ans == -1) return query(ch[x][1],ch[y][1],mid + 1,xr,mid + 1,r);return ans;}
}

int main(){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,q = in; for(int i = 1;i <= n;i++) a[i] = in,key[i] = (rnd() << 32ull) + rnd();
	for(int i = 1,u,v;i < n;i++) u = in,v = in,G[u].pb(v),G[v].pb(u);
	dfs(1,0); dfs1(1,1);
	while(q--){
		int u = in,v = in,l = in,r = in; L = lca(u,v);
		printf("%d\n",query(rt[u],rt[v],l,r));
	}
	return 0;
}
